//
//  defines.h
//  DataPlatform
//
//  Created by Liu Dafan on 12-2-13.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#ifndef DataPlatform_defines_h
#define DataPlatform_defines_h

#include <stdlib.h>
#include <inttypes.h>
#include <limits.h>
#include <string>
#include "fs_types.h"
#include "error_code.h"

class CallbackHandler
{
public:
    virtual void callback(uint32_t status, void* context) = 0;
};

class AutoLocker
{
public:
    AutoLocker(pthread_mutex_t* lock)
    {
        _lock = lock;
        pthread_mutex_lock(_lock);
    }
    
    ~AutoLocker()
    {
        pthread_mutex_unlock(_lock);
    }
    
private:
    pthread_mutex_t* _lock;
};

struct Host
{
	char name[256];
	char ip[16];
	Host *next;
};

struct Config
{
	char conf[1024];
	int connect_num;
	char hbase_host[16];
	unsigned hbase_port;
	char hdfs_host[16];
	unsigned hdfs_port;
	char memlink_host[16];
	unsigned memlink_read_port;
	unsigned memlink_write_port;
    char rootdir[256];
	Host *host;
};

Config* readconf(const char *file);

#endif
